mod image_handle_jiaye;
mod image_handle_guoyu;
mod hanjun;

#[test]
fn test_() {
    for i in 1..=6{
        let v = calc_x3(
            &format!(".\\test_image\\480\\00{}.png", i),
            &format!(".\\test_image\\480\\00{}.jpg", i),
        );
        // println!("move x:{:?}", v);
    }

}

// #[no_mangle]
pub fn test(message: &str) -> String {
    message.to_string()
}

#[no_mangle]
pub fn calc_x(block_path: &str, big_path: &str) -> f64 {
    image_handle_jiaye::calc_x(block_path, big_path)
        .map_err(|e| println!("calc_x error: {:?}", e))
        .unwrap_or(-1.)
}

/// 第二个识别验证码的方法完成,识别率在单元测试时: 8个图片能识别成功7次
#[no_mangle]
pub fn calc_x2(block_path: &str, big_path: &str) -> f64 {
    image_handle_guoyu::calc_x(block_path, big_path)
        .map_err(|e| println!("calc_x2 error: {:?}", e))
        .unwrap_or(-1.)
}

#[no_mangle]
pub fn calc_x3(block_path: &str, big_path: &str) -> f64 {
    hanjun::run(block_path.to_string(),big_path.to_string())
        .map_err(|e| println!("calc_x3 error: {:?}", e))
        .unwrap_or(-1.)
}

